package cn.migu.music.hangupsms.repository;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import cn.migu.music.hangupsms.common.entity.SettingsChangeLog;

@Mapper
public interface SettingsChangeLogMapper {

    @Select(value = "select" +
                    " id,operate_table,operate_row_id,operate_type,operate_user,operate_comment,current_content,history_content,create_time" +
                    " from t_migu_hangup_settings_change_log" +
                    " where" +
                    " operate_table=#{opTable} and operate_row_id=#{opId} and operate_type=#{opType}" +
                    " order by create_time desc limit #{size} offset #{offset}")
    List<SettingsChangeLog> selectChangeLog(@Param("opTable") String opTable,
                                            @Param("opId") String opId,
                                            @Param("opType") Integer opType,
                                            @Param("offset") Integer offset,
                                            @Param("size") Integer size);

    @Insert(value = "insert into t_migu_hangup_settings_change_log (operate_table,operate_row_id,operate_type,operate_user,operate_comment," +
                    "current_content,history_content,create_time)" +
                    " values (#{log.operateTable},#{log.operateRowId},#{log.operateType},#{log.operateUser},#{log.operateComment}" +
                    ",#{log.currentContent},#{log.historyContent},now())")
    void insert(@Param("log") SettingsChangeLog settingsChangeLog);
}
